package me.vudu.Conflict.Handlers;

import me.vudu.Conflict.ConflictPlugin;

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.SkullType;
import org.bukkit.entity.Egg;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.material.SpawnEgg;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.inventory.SpoutItemStack;
import org.getspout.spoutapi.inventory.SpoutShapedRecipe;
import org.getspout.spoutapi.material.MaterialData;

/**
 * verwaltet eigene Rezepte
 * @author vwendel
 *
 */
public class RecipeManager {
	
	/**
     * generiert alle eigenen Rezepte
     */
    public static void addRecipes(){
    	
    	
    	//Artefakt Stufe 1
    	ItemStack result_1_1 = new SpoutItemStack(ConflictPlugin.art_1_1, 1);
        SpoutShapedRecipe recipe_1_1 = new SpoutShapedRecipe(result_1_1);
        recipe_1_1.shape("TTT", " S ", " I ");
        recipe_1_1.setIngredient('I', MaterialData.ironIngot);
        recipe_1_1.setIngredient('S', MaterialData.fermentedSpiderEye);
        recipe_1_1.setIngredient('T', MaterialData.inkSac);
        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe_1_1);
        
        //Artefakt Stufe 2
    	ItemStack result_2_1 = new SpoutItemStack(ConflictPlugin.art_2_1, 1);
        SpoutShapedRecipe recipe_2_1 = new SpoutShapedRecipe(result_2_1);
        recipe_2_1.shape("   ", "GTC", "AAA");
        recipe_2_1.setIngredient('C', MaterialData.cake);
        recipe_2_1.setIngredient('T', MaterialData.tnt);
        recipe_2_1.setIngredient('G', MaterialData.goldenApple);
        recipe_2_1.setIngredient('A', ConflictPlugin.art_1_5);
        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe_2_1);
        
       //Artefakt Stufe 3
    	ItemStack result_3_1 = new SpoutItemStack(ConflictPlugin.art_3_1, 1);
        SpoutShapedRecipe recipe_3_1 = new SpoutShapedRecipe(result_3_1);
        recipe_3_1.shape("LGL", "ODO", "A A");
        recipe_3_1.setIngredient('G', MaterialData.ghastTear);
        recipe_3_1.setIngredient('L', MaterialData.lapisBlock);
        recipe_3_1.setIngredient('D', MaterialData.diamondBlock);
        recipe_3_1.setIngredient('O', MaterialData.goldBlock);
        recipe_3_1.setIngredient('A', ConflictPlugin.art_2_5);
        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe_3_1);
        
        //VuduBrick
        ItemStack result_VuduBrick = new SpoutItemStack(ConflictPlugin.vuduBrick, 4);
        SpoutShapedRecipe recipe_VB = new SpoutShapedRecipe(result_VuduBrick);
        recipe_VB.shape("S S", " I ", "S S");
        recipe_VB.setIngredient('S', MaterialData.stone);
        recipe_VB.setIngredient('I', MaterialData.brick);
        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe_VB);
        
        //EnhancedVuduBrick
        ItemStack result_EnhancedVuduBrick = new SpoutItemStack(ConflictPlugin.enhancedVuduBrick, 2);
        SpoutShapedRecipe recipe_EVB = new SpoutShapedRecipe(result_EnhancedVuduBrick);
        recipe_EVB.shape("VV ", "VV ", "   ");
        recipe_EVB.setIngredient('V', ConflictPlugin.vuduBrick);
        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe_EVB);
        
        
        //CompressedDirt
        ItemStack result_CDirtBrick = new SpoutItemStack(ConflictPlugin.cDirt, 1);
        SpoutShapedRecipe recipe_cDirt = new SpoutShapedRecipe(result_CDirtBrick);
        recipe_cDirt.shape("DDD", "DDD", "DDD");
        recipe_cDirt.setIngredient('D', MaterialData.dirt);
        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe_cDirt);
        
        //CompressedGravel
        ItemStack result_CGravelBrick = new SpoutItemStack(ConflictPlugin.cGravel, 1);
        SpoutShapedRecipe recipe_cGravel = new SpoutShapedRecipe(result_CGravelBrick);
        recipe_cGravel.shape("DDD", "DDD", "DDD");
        recipe_cGravel.setIngredient('D', MaterialData.gravel);
        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe_cGravel);
        
        
        //CompressedDirt to Iron
        ItemStack result_ironStack = new SpoutItemStack(new ItemStack(265,3));
        SpoutShapedRecipe recipe_cDirtIron = new SpoutShapedRecipe(result_ironStack);
        recipe_cDirtIron.shape("DID", "DDD", "DDD");
        recipe_cDirtIron.setIngredient('D', ConflictPlugin.cDirt);
        recipe_cDirtIron.setIngredient('I', MaterialData.ironIngot);
        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe_cDirtIron);
        
        //CompressedGravel to Iron
        SpoutShapedRecipe recipe_cGravelIron = new SpoutShapedRecipe(result_ironStack);
        recipe_cGravelIron.shape("DID", "DDD", "DDD");
        recipe_cGravelIron.setIngredient('D', ConflictPlugin.cGravel);
        recipe_cGravelIron.setIngredient('I', MaterialData.ironIngot);
        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe_cGravelIron);
        
        //DamageTowerBlock
        ItemStack result_DamageTower = new SpoutItemStack(ConflictPlugin.damageTower, 1);
        SpoutShapedRecipe recipe_DT = new SpoutShapedRecipe(result_DamageTower);
        recipe_DT.shape(" G ", "DED", " A ");
        recipe_DT.setIngredient('G', MaterialData.goldSword);
        recipe_DT.setIngredient('D', MaterialData.dispenser);
        recipe_DT.setIngredient('E', MaterialData.enderPearl);
        recipe_DT.setIngredient('A', ConflictPlugin.art_1_5);
        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe_DT);
        

        //DamageTower with Head
        ShapedRecipe recipe_DT2 = new ShapedRecipe (new ItemStack(new SpoutItemStack(ConflictPlugin.damageTower, 1)));
        recipe_DT2.shape(" G ", "DED", " A ");
        recipe_DT2.setIngredient('G', Material.GOLD_SWORD);
        recipe_DT2.setIngredient('D', Material.DISPENSER);
        recipe_DT2.setIngredient('E', Material.ENDER_PEARL);
        recipe_DT2.setIngredient('A',new ItemStack(Material.SKULL_ITEM, 1, (short)SkullType.PLAYER.ordinal()).getData() );
        Bukkit.getServer().addRecipe(recipe_DT2);
        
        
        //DefenseTowerBlock
        ItemStack result_DefenseTower = new SpoutItemStack(ConflictPlugin.defenseTower, 1);
        SpoutShapedRecipe recipe_DeT = new SpoutShapedRecipe(result_DefenseTower);
        recipe_DeT.shape(" G ", "RER", " A ");
        recipe_DeT.setIngredient('G', MaterialData.goldHelmet);
        recipe_DeT.setIngredient('R', MaterialData.redstoneRepeater);
        recipe_DeT.setIngredient('E', MaterialData.enderPearl);
        recipe_DeT.setIngredient('A', ConflictPlugin.art_1_5);
        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe_DeT);
        
        //DefenseTower with head
        ShapedRecipe recipe_DFT2 = new ShapedRecipe (new ItemStack(new SpoutItemStack(ConflictPlugin.defenseTower, 1)));
        recipe_DFT2.shape(" G ", "RER", " A ");
        recipe_DFT2.setIngredient('G', Material.GOLD_HELMET);
        recipe_DFT2.setIngredient('R', Material.DIODE);
        recipe_DFT2.setIngredient('E', Material.ENDER_PEARL);
        recipe_DFT2.setIngredient('A',new ItemStack(Material.SKULL_ITEM, 1, (short)SkullType.PLAYER.ordinal()).getData() );
        Bukkit.getServer().addRecipe(recipe_DFT2);
    	
        //RadarTowerBlock
        ItemStack result_RadarTower = new SpoutItemStack(ConflictPlugin.radarTower, 1);
        SpoutShapedRecipe recipe_RT = new SpoutShapedRecipe(result_RadarTower);
        recipe_RT.shape(" C ", " E ", " A ");
        recipe_RT.setIngredient('C', MaterialData.compass);
        recipe_RT.setIngredient('E', MaterialData.enderPearl);
        recipe_RT.setIngredient('A', ConflictPlugin.art_1_5);
        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe_RT);
        
        //RadarTower with head
        ShapedRecipe recipe_RT2 = new ShapedRecipe (new ItemStack(new SpoutItemStack(ConflictPlugin.radarTower, 1)));
        recipe_RT2.shape(" C ", " E ", " A ");
        recipe_RT2.setIngredient('C', Material.COMPASS);
        recipe_RT2.setIngredient('E', Material.ENDER_PEARL);
        recipe_RT2.setIngredient('A',new ItemStack(Material.SKULL_ITEM, 1, (short)SkullType.PLAYER.ordinal()).getData() );
        Bukkit.getServer().addRecipe(recipe_RT2);
        
        
        //BaseSeekerBlock 1
        ItemStack result_BaseSeeker1 = new SpoutItemStack(ConflictPlugin.baseSeeker_1, 1);
        SpoutShapedRecipe recipe_BS = new SpoutShapedRecipe(result_BaseSeeker1);
        recipe_BS.shape("   ", " M ", " A ");
        recipe_BS.setIngredient('M', MaterialData.map);
        //recipe_BS.setIngredient('E', MaterialData.enderPearl);
        recipe_BS.setIngredient('A', ConflictPlugin.art_1_5);
        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe_BS);
        
        //BaseSeekerBlock 2
//        ItemStack result_BaseSeeker2 = new SpoutItemStack(ConflictPlugin.baseSeeker2, 1);
//        SpoutShapedRecipe recipe_BS2 = new SpoutShapedRecipe(result_BaseSeeker2);
//        recipe_BS2.shape("   ", " E ", " A ");
//        recipe_BS2.setIngredient('E', ConflictPlugin.baseSeeker_5);
//        recipe_BS2.setIngredient('A', ConflictPlugin.art_1_5);
//        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe_BS2);
        
        //ChainMail
        //Helm
        ItemStack result_chainHelm = new SpoutItemStack(302);
        SpoutShapedRecipe recipe_chainHelm = new SpoutShapedRecipe(result_chainHelm);
        recipe_chainHelm.shape("RRR", "RLR", "   ");
        recipe_chainHelm.setIngredient('R', MaterialData.ironIngot);
        recipe_chainHelm.setIngredient('L', MaterialData.lavaBucket);
        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe_chainHelm);
        
        //Plate
        ItemStack result_chainPlate = new SpoutItemStack(303);
        SpoutShapedRecipe recipe_chainPlate= new SpoutShapedRecipe(result_chainPlate);
        recipe_chainPlate.shape("RLR", "RLR", "RRR");
        recipe_chainPlate.setIngredient('R', MaterialData.ironIngot);
        recipe_chainPlate.setIngredient('L', MaterialData.lavaBucket);
        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe_chainPlate);

        
        //Leggins
        ItemStack result_chainLeggins = new SpoutItemStack(304);
        SpoutShapedRecipe recipe_chainLeggins = new SpoutShapedRecipe(result_chainLeggins);
        recipe_chainLeggins.shape("RRR", "RLR", "R R");
        recipe_chainLeggins.setIngredient('R', MaterialData.ironIngot);
        recipe_chainLeggins.setIngredient('L', MaterialData.lavaBucket);
        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe_chainLeggins);

        
        //Shoes
        ItemStack result_chainShoes = new SpoutItemStack(305);
        SpoutShapedRecipe recipe_chainShoes = new SpoutShapedRecipe(result_chainShoes);
        recipe_chainShoes.shape("   ", "RLR", "R R");
        recipe_chainShoes.setIngredient('R', MaterialData.ironIngot);
        recipe_chainShoes.setIngredient('L', MaterialData.lavaBucket);
        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe_chainShoes);

        
        
        
        //Converter ERZ+Redstone -> Diamant
        SpoutShapedRecipe recipe_diam1 = new SpoutShapedRecipe(new SpoutItemStack(MaterialData.diamond, 1));
        recipe_diam1.shape(" I ", "RRR", "RRR");
        recipe_diam1.setIngredient('R', MaterialData.redstone);
        recipe_diam1.setIngredient('I', MaterialData.ironBlock);
        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe_diam1);
        
        SpoutShapedRecipe recipe_diam2 = new SpoutShapedRecipe(new SpoutItemStack(MaterialData.diamond, 1));
        recipe_diam2.shape(" L ", "RRR", "RRR");
        recipe_diam2.setIngredient('R', MaterialData.redstone);
        recipe_diam2.setIngredient('L', MaterialData.lapisBlock);
        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe_diam2);
        
        SpoutShapedRecipe recipe_diam3 = new SpoutShapedRecipe(new SpoutItemStack(MaterialData.diamond, 1));
        recipe_diam3.shape(" I ", " L ", "   ");
        recipe_diam3.setIngredient('I', MaterialData.ironBlock);
        recipe_diam3.setIngredient('L', MaterialData.lapisBlock);
        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe_diam3);
        
        //Converter ERZ+Redstone -> Gold
        SpoutShapedRecipe recipe_gold1 = new SpoutShapedRecipe(new SpoutItemStack(MaterialData.goldIngot, 1));
        recipe_gold1.shape("III", "III", "RRR");
        recipe_gold1.setIngredient('R', MaterialData.redstone);
        recipe_gold1.setIngredient('I', MaterialData.ironIngot);
        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe_gold1);
        
        SpoutShapedRecipe recipe_gold2 = new SpoutShapedRecipe(new SpoutItemStack(MaterialData.goldIngot, 1));
        recipe_gold2.shape("LLL", "LLL", "RRR");
        recipe_gold2.setIngredient('R', MaterialData.redstone);
        recipe_gold2.setIngredient('L', MaterialData.lapisLazuli);
        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe_gold2);
        
        SpoutShapedRecipe recipe_gold3 = new SpoutShapedRecipe(new SpoutItemStack(MaterialData.goldIngot, 1));
        recipe_gold3.shape("III", "LIL", "LLL");
        recipe_gold3.setIngredient('I', MaterialData.ironIngot);
        recipe_gold3.setIngredient('L', MaterialData.lapisLazuli);
        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe_gold3);
        
        
        //SpawnEgg egg = new SpawnEgg();
        //egg.setSpawnedType(EntityType.GHAST);
        
        SpoutShapedRecipe recipe_egg = new SpoutShapedRecipe(new ItemStack(Material.MONSTER_EGG, 1, (short)56));
        recipe_egg.shape("NNN", "NNN", "NNN");
        recipe_egg.setIngredient('N', MaterialData.netherrack);
        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe_egg);
        
        
        
   
        ShapedRecipe recipe_head = new ShapedRecipe (new ItemStack(Material.SKULL_ITEM, 1, (short)SkullType.CREEPER.ordinal()));
        recipe_head.shape("III", "III", "III");
        recipe_head.setIngredient('I',new ItemStack(Material.SKULL_ITEM, 1, (short)SkullType.SKELETON.ordinal()).getData() );
        Bukkit.getServer().addRecipe(recipe_head);
        
        ShapedRecipe recipe_head2 = new ShapedRecipe (new ItemStack(Material.GHAST_TEAR));
        recipe_head2.shape("   ", "   ", "III");
        recipe_head2.setIngredient('I',new ItemStack(Material.SKULL_ITEM, 1, (short)SkullType.CREEPER.ordinal()).getData() );
        Bukkit.getServer().addRecipe(recipe_head2);
        

    }

}
